<?php

namespace App\Http\Controllers\Biz;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;

use App\Repositories\Eloquent\Mgt\UserRepository as User;
use App\Repositories\Eloquent\Mgt\BookRepository as Book;
use App\Repositories\Eloquent\Mgt\ActivityRepository as Activity;
use App\Repositories\Eloquent\Biz\BorrowRepository as Borrow;

class BorrowController extends Controller
{
    protected $user, $activity, $book, $borrow;

    public function __construct(User $user, Activity $activity, Book $book, Borrow $borrow)
    {
        parent::__construct();

        $this->user = $user;
        $this->activity = $activity;
        $this->book = $book;
        $this->borrow = $borrow;
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function borrow(Request $request)
    {
        return $this->user->borrow($request);
    }


    public function return(Request $request)
    {
        return $this->user->return($request);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $query = $request->query('query');

        $borrows = $this->borrow->index($query)->paginate(60);

        return view($this->view, compact('borrows'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param int $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param int $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param \Illuminate\Http\Request $request
     * @param int $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param int $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }


    public function getEnumeration()
    {
        return $this->enum->index()->get();
    }
}
